package com.my.vote.entity.req;

import android.text.TextUtils;

import com.my.vote.entity.EVoteItem;

import java.util.ArrayList;
import java.util.List;

/**
 * 新增投票【请求参数】
 *
 * @date 2018/4/14
 */
public class ReqAddVote  {

    String voteUrl;

    String title;

    /**
     * 介绍
     */
    String introduce;

    /**
     * 当前模式 1 可以参加报名模式， 2 只能投票模式
     */
    String type;

    /**
     * 投票模式 1 只能投票一个， 2 只能投票2个 依次类推
     */
    int voteType;
    /**
     * 投票结束时间
     */
    Double voteEndTime;

    /**
     * 报名结束时间
     */
    Double enrollEndTime;

    /***
     * 选项
     */
    List<EVoteItem> item;

    public Double getVoteEndTime() {
        return voteEndTime;
    }

    public void setVoteEndTime(Double voteEndTime) {
        this.voteEndTime = voteEndTime;
    }

    public Double getEnrollEndTime() {
        return enrollEndTime;
    }

    public void setEnrollEndTime(Double enrollEndTime) {
        this.enrollEndTime = enrollEndTime;
    }

    public String getVoteUrl() {
        return voteUrl;
    }

    public void setVoteUrl(String voteUrl) {
        this.voteUrl = voteUrl;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getIntroduce() {
        return introduce;
    }

    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getVoteType() {
        return voteType;
    }

    public void setVoteType(int voteType) {
        this.voteType = voteType;
    }

    public void addItem(EVoteItem item) {
        if (this.item == null) {
            this.item = new ArrayList<>(3);
        }
        this.item.add(item);
    }

    public void removeItem(EVoteItem data) {
        if (this.item == null) {
            return;
        }
        final int size = this.item.size();
        for (int i = 0; i < size; i++) {
            if (TextUtils.equals(data.getTitle(), item.get(i).getTitle()) && TextUtils.equals(data.getIntroduce(), item.get(i).getIntroduce())) {
                item.remove(i);
                return;
            }
        }
    }

    public List<EVoteItem> getItem() {
        if (this.item == null) {
            this.item = new ArrayList<>(0);
        }
        return item;
    }

    public void setItem(List<EVoteItem> item) {
        this.item = item;
    }
}
